import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/common/dashed_line.dart';
import 'package:cbec_app/components/common/recommend.dart';
import 'package:cbec_app/pages/goods/controller/pay_success_ctr.dart';
import 'package:cbec_app/routes/routes.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../utils/EventMgr.dart';

//支付成功页面

class PaySuccess extends GetView<PaySuccessController> {
  const PaySuccess({super.key});

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        bool isTargetRouteFound = false;
        Get.until((route) {
          if (route.settings.name == Routes.main) {
            isTargetRouteFound = true;
          }
          return isTargetRouteFound;
        });
        // 如果找到特定页面，允许返回，否则不允许
        return isTargetRouteFound;
      },
      child: GetBuilder<PaySuccessController>(builder: (controller) {
        return BasePage(
          title: '',
          iconType: IconType.none,
          gradient: LinearGradient(colors: [Tools.fromHex("#EA7A53"), Tools.fromHex("#E44930"), Tools.fromHex("#E23F29")]),
          bodyColor: Colors.transparent,
          children: [
            Container(
              padding: EdgeInsets.only(left: 67.w),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Text("支付成功", style: setTextStyle(18, FontWeight.bold, Tools.fromHex("#FFFFFF"))),
                      SizedBox(width: 10.w),
                      Container(
                        decoration: border_radis(Tools.fromHex("#E97E6E"), radiusValue: 15),
                        child: Icon(Icons.check, size: 25, color: Tools.fromHex("#FFFFFF")),
                      ),
                    ],
                  ),
                  SizedBox(height: 20.w),
                  Container(
                    child: Text("实付￥${controller.price}", style: setTextStyle(12, FontWeight.normal, Tools.fromHex("#FFFFFF"))),
                  ),
                  SizedBox(height: 10.w),
                  // Container(
                  //   child: Text("微信支付", style: setTextStyle(12, FontWeight.normal, Tools.fromHex("#FFFFFF"))),
                  // ),
                ],
              ),
            ),
            // 虚线
            Container(
              margin: EdgeInsets.only(top: 20.w),
              padding: EdgeInsets.only(left: 18.w, right: 18.w),
              child: DashedLind(
                axis: Axis.horizontal,
                dashedWidth: 5.w,
                color: Tools.fromHex("#FFFFFF"),
                count: 30,
              ),
            ),
            // 按钮
            Container(
              margin: EdgeInsets.only(top: 40.w, bottom: 45.w),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  solidButton("查看订单", () {
                    Get.until((route) => route.settings.name == Routes.main);
                    EventMgr.send(EventType.exchangeNav, 'my');

                    Future.delayed(const Duration(milliseconds: 500), () {
                      Get.toNamed(Routes.myOrder);
                    });
                  }, backgroundColor: Tools.fromHex("#EA7A53"), width: 96, height: 28, borderColor: Colors.white, textColor: Colors.white),
                  SizedBox(width: 20.w),
                  solidButton("返回首页", () {
                    Get.until((route) => Get.currentRoute == Routes.main);
                  }, width: 96, height: 28, backgroundColor: Tools.fromHex("#FFFFFF"), textColor: Tools.fromHex("#333333")),
                ],
              ),
            ),
            // 自定义广告窗
            Container(
              decoration: BoxDecoration(
                borderRadius: const BorderRadius.only(
                  topLeft: Radius.circular(20.0),
                  topRight: Radius.circular(20.0),
                ),
                color: Tools.fromHex("#F3F5F7"),
              ),
              child: Column(
                children: [
                  BaseInteractive(
                    onClick: () {
                      Get.until((route) => Get.currentRoute == Routes.main);
                    },
                    childWidget: Container(
                      alignment: Alignment.center,
                      height: 270.h,
                      decoration: border_radis(Colors.white),
                      child: Text(""),
                    ),
                  ),
                  Recommend(location: "PaySuccess"),
                ],
              ),
            ),
          ],
        );
      }),
    );
  }
}
